home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jumping_jelly_beans.swf
/
scripts
/
frame_10
/
DoAction.as
Wrap
Text File
|
2006-11-29
|
11KB
|
509 lines
MovieClip.prototype.make = function(tipe, x)
{
if(!x)
{
x = 620;
}
if(!tipe)
{
m.attachmovie("ff","a" + r.ad,r.ad);
m["a" + r.ad]._x = x;
var op = 0;
if(r.ypos.length > 1)
{
if(random(100) > 50)
{
var op = 1;
}
}
m["a" + r.ad]._y = r.ypos[op];
}
else if(tipe == 2)
{
m.attachmovie("fire","a" + r.ad,r.ad);
m["a" + r.ad]._x = 630;
m["a" + r.ad]._y = 390;
}
else if(tipe == 9)
{
m.attachmovie("bonus","bonus" + r.ad,r.ad);
m["bonus" + r.ad]._x = 630;
m["bonus" + r.ad]._y = r.ypos[0];
var tp = 1;
if(r.timepassed < 3000)
{
if(r.time > 0.8 * r.timemax)
{
if(random(100) < 70)
{
tp = 2;
}
}
}
else if(random(100) < 70)
{
tp = 2;
}
m["bonus" + r.ad].tipe = tp;
}
r.ad = r.ad + 1;
};
MovieClip.prototype.flick = function()
{
var t = this;
t.onEnterFrame = function()
{
t._alpha = 70 + random(30);
};
};
MovieClip.prototype.run = function()
{
var t = this;
t.no = Number(t._name.substr(2,1));
t.onEnterFrame = function()
{
t._x = m["sh" + t.no]._x = r.xpos[t.no] + (t._x - r.xpos[t.no]) / 1.1;
if(t.hit)
{
delete t.onEnterFrame;
t.gotoAndPlay("hitt");
}
else if(r.pres == t.no)
{
delete t.onEnterFrame;
t.gotoAndPlay("follow");
}
t.cekinv();
};
t.stop();
};
MovieClip.prototype.follow = function()
{
var t = this;
t.swapDep(r.pd);
t.onEnterFrame = function()
{
t.nx = r._xmouse;
t.ceklimits();
t._x = m["sh" + t.no]._x = t.nx + (t._x - t.nx) / 1.4;
if(t.hit)
{
delete t.onEnterFrame;
t.gotoAndPlay("hitt");
}
else if(!r.pres)
{
delete t.onEnterFrame;
t.gotoAndPlay("jump");
}
t.cekinv();
};
t.stop();
};
MovieClip.prototype.cekhitob = function()
{
var n = 1;
while(n <= 3)
{
if(!r.jump[n])
{
var t = m["p" + n];
if(!t.hit and t.inv <= 0)
{
if(t.z2.hitTest(this.z))
{
t.hit = 1;
}
}
}
n++;
}
};
MovieClip.prototype.cekgot = function()
{
var res = 0;
var n = 1;
while(n <= 3)
{
if(r.jump[n])
{
var t = m["p" + n];
if(t.c > r.minc[n] and t.c < r.maxc[n])
{
if(t.p.arm.net.z.hitTest(this._x,this._y,1))
{
t.got = t.got + 1;
r.got = r.got + 1;
t.xgot = this._x;
res = t;
break;
}
}
}
n++;
}
return res;
};
MovieClip.prototype.cekinv = function()
{
var t = this;
t.clr = new color(t);
if(t.inv > 0)
{
t.inv--;
t._visible = !t._visible;
if(!t.inv)
{
t.clr.resetcolor();
}
}
else
{
t._visible = 1;
}
};
MovieClip.prototype.hitt = function()
{
var t = this;
t._y = r.yland - 8;
r.time = Math.max(0,r.time - r.timehit);
r.timebar.frame.play();
t.ys = -20;
t.gra = 10;
r.zhit.start();
t.onEnterFrame = function()
{
t._y += t.ys;
t.ys += t.gra;
if(t._y >= r.yland)
{
t._y = r.yland;
delete t.onEnterFrame;
t.inv = r.invhitdelay;
t.clr = new color(t);
t.clr.setBrightness(20);
t.hit = 0;
t.gotoAndPlay("run");
}
};
t.stop();
};
MovieClip.prototype.jump = function()
{
var t = this;
t.ys = r.jumppower[t.no];
r.jump[t.no] = 1;
t.c = 1;
t.uda = 0;
t.got = 0;
t.onEnterFrame = function()
{
t.cekinv();
t.c = t.c + 1;
if(t.c == r.maxc[t.no] + 4)
{
if(t.got > 1)
{
showgot(t.got,t.no,t.xgot - 20,t.tipenet);
}
}
t._y += t.ys;
t.ys += r.grav[t.no];
if(t.ys > 1)
{
if(!t.uda)
{
t.uda = 1;
r.xpos[t.no] = t._x;
var allpos = [];
var f = 0;
while(f < 3)
{
allpos.push({no:f + 1,x:r.xpos[f + 1]});
f++;
}
allpos.sortBy("x");
var f = 0;
while(f < 3)
{
if(allpos[f].no == t.no)
{
var startno = f;
}
f++;
}
if(startno < 2)
{
var f = startno + 1;
while(f < 3)
{
if(allpos[f].x - t._x < r.spacing)
{
var nx = Math.min(t._x + r.spacing,r.xmax);
allpos[f].x = r.xpos[allpos[f].no] = nx;
}
f++;
}
}
if(startno > 0)
{
var f = startno - 1;
while(f >= 0)
{
if(t._x - allpos[f].x < r.spacing)
{
var nx = Math.max(t._x - r.spacing,r.xmin);
allpos[f].x = r.xpos[allpos[f].no] = nx;
}
f--;
}
}
}
if(t._y >= r.yland)
{
t._y = r.yland;
r.jump[t.no] = 0;
t.swapDep(r.pd2);
delete t.onEnterFrame;
t.gotoAndPlay("run");
}
}
};
t.stop();
};
MovieClip.prototype.showgot = function(got, no, x, tipenet)
{
m.attachMovie("got","got" + r.ad,r.ad);
m["got" + r.ad]._x = x;
m["got" + r.ad]._y = r.yposnormal[no - 1];
m["got" + r.ad].got = got;
m["got" + r.ad].tipenet = tipenet;
r.ad = r.ad + 1;
};
MovieClip.prototype.swapDep = function(d)
{
this.swapDepths(d);
this.dep = d;
};
MovieClip.prototype.initz = function()
{
this._visible = 0;
};
movieclip.prototype.ceklimits = function()
{
this.nx = Math.max(this.nx,r.xmin);
this.nx = Math.min(this.nx,r.xmax);
};
MovieClip.prototype.jiggle = function(beginska, dv, dvstep)
{
var t = this;
if(!beginska)
{
beginska = 150;
}
t._xscale = t._yscale = beginska;
t.ska = 100;
t.dx = 0;
t.dy = 0;
if(!dv)
{
t.dv = 0.9;
}
else
{
t.dv = dv;
}
if(!dvstep)
{
t.dvstep = 0.5;
}
else
{
t.dvstep = dvstep;
}
t.onenterframe = function()
{
t.dx = t.dx * t.dvstep + (t.ska - t._xscale) * t.dv;
t.dy = t.dy * t.dvstep + (t.ska - t._yscale) * t.dv;
t._xscale += t.dx;
t._yscale += t.dy * 1.5;
};
};
Array.prototype.removeElement = function(i)
{
if(i == null)
{
i = 0;
}
var r = this[i];
var j = i;
while(j < this.length - 1)
{
this[j] = this[j + 1];
j++;
}
this.pop();
return r;
};
Array.prototype.removeValue = function(a)
{
var i = 0;
while(i < this.length)
{
if(a == this[i])
{
this.removeElement(i);
}
i++;
}
};
Array.prototype.randomize = function()
{
return this.sort(function(a, b)
{
return Math.floor(Math.random() * 2) != 0 ? -1 : 1;
}
);
};
Array.prototype.copy = Array.prototype.slice;
Movieclip.prototype.fadescreen = function(speed)
{
if(!speed)
{
var speed = 5;
}
_root.createEmptyMovieClip("dark",100001);
var d = _root.dark;
with(d)
{
lineStyle(1,0,100);
beginfill(0,100);
moveto(-5000,-5000);
lineto(5000,-5000);
lineto(5000,5000);
lineto(-5000,5000);
endfill();
d.onEnterFrame = function()
{
_alpha -= speed;
if(_alpha <= 0)
{
removeMovieClip("");
stop();
}
};
}
};
Array.prototype.sortBy = function(key)
{
var comparisonFunction = function(a, b)
{
var aTemp = typeof a[key] != "string" ? a[key] : a[key].toLowerCase();
var bTemp = typeof b[key] != "string" ? b[key] : b[key].toLowerCase();
if(aTemp < bTemp)
{
return -1;
}
if(aTemp > bTemp)
{
return 1;
}
return 0;
};
this.sort(comparisonFunction);
};
Movieclip.prototype.findang = function(dx, dy)
{
return deg(math.atan2(dy,dx));
};
Movieclip.prototype.rad = function(qdeg)
{
return qdeg * 0.017453292519943295;
};
Movieclip.prototype.deg = function(qrad)
{
return qrad * 57.29577951308232;
};
Color.prototype.setBrightness = function(value)
{
this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
var trans = this.getTransform();
var percent = Math.abs(value) / 100;
var brightnessColor = value <= 0 ? 0 : 255;
with(trans)
{
ra -= ra * percent;
ga -= ga * percent;
ba -= ba * percent;
rb += (brightnessColor - rb) * percent;
gb += (brightnessColor - gb) * percent;
bb += (brightnessColor - bb) * percent;
}
this.setTransform(trans);
};
Color.prototype.resetcolor = function()
{
this.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
Sound.prototype.fade = function(fadeType, fadeDuration)
{
this.fadeDuration = fadeDuration * 1000 / 100;
this.fadeType = fadeType;
this.currentVolume = this.getVolume();
this.intID = setInterval(function(thisObj)
{
thisObj.doFade(thisObj.fadeType);
}
,this.fadeDuration,this);
this.doFade = function(fadeType)
{
if(fadeType == "out")
{
this.setVolume(this.currentVolume--);
if(this.getVolume() <= 0)
{
clearInterval(this.intID);
}
}
else if(fadetype == "in")
{
this.setVolume(this.currentVolume++);
if(this.getVolume() >= 100)
{
clearInterval(this.intID);
}
}
};
};
movieclip.prototype.wait = function(delay)
{
this.createEmptyMovieClip("wdl",55555);
this.wdl.delay = delay;
this.wdl.onenterframe = function()
{
this.delay--;
if(!this.delay)
{
delete this.onenterframe;
this._parent.play();
this.removeMovieClip();
}
};
this.stop();
};
MovieClip.prototype.savecookie = function(vari, value)
{
var so = SharedObject.getLocal("lazcookie","/");
so.data[vari] = value;
so.flush();
};
MovieClip.prototype.loadcookie = function(vari)
{
var so = SharedObject.getLocal("lazcookie","/");
if(so.data[vari] != null)
{
return so.data[vari];
}
return false;
};